#!/bin/bash

processo=`ps -ef | grep "gdplivre.py start" | grep -v grep | awk '{print $2}'`
echo "processo:" $processo


if [ ! -s /tmp/db.cfg ]
then
	cp database/db.cfg /tmp
fi

if [ "$1" = "k" ]
then
	echo "matando processo $processo"
	kill $processo
elif [ "$1" = "s" ]
then
	echo "subindo gdplivre"
	./gdplivre.py start
elif [ "$1" = "r" ]
then
	echo "deletando log"
	rm -f /tmp/gdplivre.log
elif [ "$1" = "t" ]
then
	echo "mostrando log"
	tail -f /tmp/gdplivre.log
elif [ "$1" = "v" ]
then
	echo "vendo log"
	vi /tmp/gdplivre.log
elif [ "$1" = "p" ]
then
	echo "processando processamento"
	./processamento/processamento.py

elif [ "$1" = "" ]
then
	echo 
else
	echo "Flag Inexistente!"
fi
